package com.gitee.ed.arithmetic.leetcode.question.question_1_100.question_1_10;

import com.gitee.ed.arithmetic.leetcode.SolutionRunner;
import com.gitee.ed.arithmetic.leetcode.common.Question;
import com.gitee.ed.arithmetic.leetcode.solution.solution_1_100.solution_1_10.Solution3;

/**
 * @author hongda.li
 */
public class Question3 implements Question<Solution3> {
    @Override
    public String link() {
        return "https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/";
    }

    @Override
    public String title() {
        return "3.无重复字符的最长子串";
    }

    @Override
    public String description() {
        return "给定一个字符串 s ，请你找出其中不含有重复字符的最长子串的长度。";
    }

    @Override
    public void test(Solution3 solution) {
        this.test1(solution);

        this.test2(solution);

        this.test3(solution);
    }

    private void test1(Solution3 solution) {
        int expect = 3;
        int actual = solution.lengthOfLongestSubstring("abcabcbb");
        SolutionRunner.checkString(expect, actual);
    }

    private void test2(Solution3 solution) {
        int expect = 1;
        int actual = solution.lengthOfLongestSubstring("bbbbb");
        SolutionRunner.checkString(expect, actual);
    }

    private void test3(Solution3 solution) {
        int expect = 3;
        int actual = solution.lengthOfLongestSubstring("pwwkew");
        SolutionRunner.checkString(expect, actual);
    }
}
